Skip to main content

Pataa AutoFill iOS SDK Implementation Guide

Install SDK

To use the Pataa Autofill iOS SDK, you have two options. You can manually install it by including the SDK source code in your Xcode project.

Follow the steps for a Cocoapods install:

In your project root directory run this command on terminal

pod init

then open open podfile and past this in your project podfile

pod 'Address-Autofill-iOS'

then save and run this command on terminal

pod install

Follow the steps below for a manual install:

  1. Download and unzip the PataaAutoFillSDK

  2. Drag the PataaAutoFillSDK.xcframework inside your project under the main project file. Embed the framework.

  3. Select your project.xcodeproj file. Under General, add the PataaAutoFillSDK framework in the Frameworks, Libraries & Embedded Content section.

Manual Install

Integration Steps for Objective-C

Follow the steps below for Objective-C:

  1. Import PataaAutoFillSDK.h to your ViewController.h file.

  2. Import PataaAutoFillSDK.h into every class where you plan to use this SDK.

#import<PataaAutoFillSDK/PataaAutoFillSDK.h>

objective

  1. Create a UIView on your UIViewController on the storyboard/xib & assign PataaAutoFillView class & create an IBOutlet of that UIView on your ViewController class.

objective3

  1. Initialize SDK with your key in ViewDidLoad() method.
[objectName initializeSDKWithKey:@"YOUR_API_KEY"];

objective4

Integration Steps for Swift

Follow the steps below for Swift:

  1. Import PataaAutoFillSDK to your ViewController.swift file.
  2. Import PataaAutoFillSDK into every class where you plan to use this SDK.
import PataaAutoFillSDK

swift

  1. Create a UIView on your UIViewController on the storyboard/xib & assign PataaAutoFillView class & create an IBOutlet of that UIView on your ViewController class

swift

  1. Initialize SDK with your key in ViewDidLoad() method.
pataaAutoFillView.initializeSDK(withKey: "YOUR_API_KEY")

swift

Get Pataa Details

Follow the steps below for Objective-C

To get the details of entered pataa code. Please assign the PataaAutoFillDelegate to your view controller & implement PataaAutoFillDelegate in your ViewController.h file

objective

[objecName setDelegate:self];

After that please implement the delegate methods in your view controller inside a ViewController.m file.

objective

(void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
}

(void)didReceivedAddressDetails:(nullable AddressDetails *)addressDetails {
}

In PAPataaDetails, You will get all the details of your pataa & user. To get the pataa details please use the following code:

(void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
NSLog(@"%@", addressDetails.address1)
NSLog(@"%@", addressDetails.address2)
NSLog(@"%@", addressDetails.address3)
NSLog(@"%@", addressDetails.address4)
NSLog(@"%@", addressDetails.cityName)
NSLog(@"%@", addressDetails.stateName)
NSLog(@"%@", addressDetails.countryName)
}

To get the user details please use the following code:

(void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
NSLog(@"%@", pataaDetails.user.mobile)
NSLog(@"%@", pataaDetails.user.countryCode)
NSLog(@"%@", pataaDetails.user.firstName)
NSLog(@"%@", pataaDetails.user.lastName)
}

If the user didn’t allow location permission & try to create a pataa then you will get all details in this delegate method.

(void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {

NSLog(@"%@", addressDetails.address1)
NSLog(@"%@", addressDetails.address2)
NSLog(@"%@", addressDetails.address3)
NSLog(@"%@", addressDetails.address4)
NSLog(@"%@", addressDetails.cityName)
NSLog(@"%@", addressDetails.stateName)
NSLog(@"%@", addressDetails.countryName)
}

Follow the steps below for Swift

To get the details of entered pataa code. Please assign the PataaAutoFillDelegate to your view controller.

objectName.delegate = self

swift

After that please implement the delegate methods in your view controller inside a UIViewController or using an extension.

swift

extension ViewController: PataaAutoFillDelegate {
func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
}

func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
}
}

In PAPataaDetails, You will get all the details of your pataa & user. To get the pataa details please use the following code

extension ViewController: PataaAutoFillDelegate {
func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
if let pataaDetails = pataaDetails, let pataa = pataaDetails.pataa {
print(pataa.pataaCode)
print(pataa.address1)
print(pataa.address2)
print(pataa.address3)
print(pataa.zipcode)
print(pataa.cityName)
print(pataa.stateName)
print(pataa.countryName)
}
}

func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
if let addressDetails = addressDetails {
print(addressDetails.address1)
print(addressDetails.address2)
print(addressDetails.address3)
print(addressDetails.zipcode)
print(addressDetails.cityName)
print(addressDetails.stateName)
print(addressDetails.countryName)
print(addressDetails.firstName)
print(addressDetails.lastName)
}
}
}

To get the user details please use the following code

func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
if let pataaDetails = pataaDetails, let user = pataaDetails.user {
print(user.countryCode)
print(user.firstName)
print(user.lastName)
print(user.mobile)
}
}

If the user didn’t allow location permission & try to create a pataa then you will get all details in this delegate method.

func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
if let addressDetails = addressDetails {
print(addressDetails.address1)
print(addressDetails.address2)
print(addressDetails.address3)
print(addressDetails.zipcode)
print(addressDetails.cityName)
print(addressDetails.stateName)
print(addressDetails.countryName)
print(addressDetails.firstName)
print(addressDetails.lastName)
}
}